package com.ttsx.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ttsx.pojo.dto.refund.RefundQueryDTO;
import com.ttsx.pojo.entity.Refund;
import com.ttsx.service.RefundService;
import com.ttsx.mapper.RefundMapper;
import org.springframework.stereotype.Service;

/**
 * @author lucky
 * @description 针对表【ttsx_refund(退款表)】的数据库操作Service实现
 * @createDate 2025-11-07 19:48:54
 */
@Service
public class RefundServiceImpl extends ServiceImpl<RefundMapper, Refund>
        implements RefundService {

    @Override
    public PageInfo<Refund> getPage(Integer pIndex, Integer pSize, RefundQueryDTO refundQueryDTO) {
        PageHelper.startPage(pIndex, pSize);

        Integer status = refundQueryDTO.getStatus();

        LambdaQueryWrapper<Refund> lqw = new LambdaQueryWrapper<>();
        lqw.eq(status != null, Refund::getRefundStatus, status);

        lqw.orderByDesc(Refund::getCreateTime);

        return new PageInfo<>(list(lqw), 5);
    }
}




